package com.wbao.dianniu.db;


import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class SqliteHelper extends SQLiteOpenHelper {
	
	 public static final String TB_NAME= "user";
	 public static final String CONFIG_TAB = "config";
	 private final String CREAT_USER_TAB = "CREATE TABLE IF NOT EXISTS "+
             TB_NAME+ "("+
             UserInfo. ID+ " integer primary key,"+
             UserInfo. MOBILE+ " varchar,"+
             UserInfo. TOKEN+ " varchar,"+
             UserInfo. USERNAME+ " varchar,"+
             UserInfo. PASSWORD+ " varchar,"+
             UserInfo. USERICON+ " blob"+
             ")";
	 private final String CREAT_CONFIG_TAB = "CREATE TABLE IF NOT EXISTS "+
			 CONFIG_TAB + "("+
             ConfigInfo. ID+ " integer primary key,"+
             ConfigInfo. SERVICE_URL+ " varchar,"+
             ConfigInfo.SERVICE_PORT+ " integer"+
             ")";
	 
	public SqliteHelper(Context context, String name, CursorFactory factory,
			int version) {
		super(context, name, factory, version);
	}

	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		db.execSQL(CREAT_USER_TAB);
		db.execSQL(CREAT_CONFIG_TAB);
		  Log. e("Database" ,"onCreate" );
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL( "DROP TABLE IF EXISTS " + TB_NAME );
        onCreate(db);
        Log. e("Database" ,"onUpgrade" );
	}

	
}
